package thread.threaddemo;

/**
 * @Author: wenjingyuan
 * @Date: 2022/11/03/16:46
 * @Description:线程状态的演示
 */
public class ThreadDemoByState {
    public static void main(String[] args) throws InterruptedException {
        Thread thread=new Thread(new Runnable() {
            @Override
            public void run() {
                //打印线程的状态
                System.out.println("线程的状态2："+Thread.currentThread().getState());
            }
        });
        //在启动之前先打印一下线程的状态
        System.out.println("线程的状态"+ thread.getState());
        thread.start();
        //让线程在休眠500ms之后在观察一下
        Thread.sleep(500);
        System.out.println("线程的状态3"+ thread.getState());
    }
}
